#pragma once
#if !defined(AFX_CHARACTERVIEW_H__292645C8_DA72_4DD9_85AC_A177E0ADC651__INCLUDED_)
#define AFX_CHARACTERVIEW_H__292645C8_DA72_4DD9_85AC_A177E0ADC651__INCLUDED_


#ifndef __AFXEXT_H__
#include <afxext.h>
#endif
#include "SelectMap.h"

class ItemList : public CDialog
{
	DECLARE_DYNCREATE(ItemList)
public:
	enum { IDD = IDD_ITEMLIST_DLG  };
	enum
	{
		Type_Item,
		Type_Equip,
	};
public:
	ItemList(void) : CDialog( ItemList::IDD )
	{};
	virtual ~ItemList(){};

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	DECLARE_MESSAGE_MAP()		


public:
	void GetItemList( int itemType );
	void GetEquipList( int characterSex, int characterClass, int caracterPart = PART_MAX );
	CListBox	m_ItemList;
	CListBox	m_TextureList;
	int m_SelectPart;
	int m_ItemType;
	int m_SelectSex;
	int m_SelectClass;
public:
	afx_msg void OnLbnSelchangeItemlist();
	virtual BOOL OnInitDialog();
public:
	afx_msg void OnLbnSelchangeTexturelist();
};

class CharacterView : public CFormView
{
public:
	struct  SEVERANIKEY
	{
		float zPos;
		DWORD dwTime;	
	};

	DECLARE_DYNCREATE(CharacterView)
public:
	enum { IDD = IDD_CHARACTER_VIEW };

protected:
	CharacterView(void);
	virtual ~CharacterView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	DECLARE_MESSAGE_MAP()

public:
	afx_msg void OnBnClickedHead();
	afx_msg void OnBnClickedFace();
	afx_msg void OnBnClickedBody();
	afx_msg void OnBnClickedHand();
	afx_msg void OnBnClickedFoot();
	afx_msg void OnBnClickedSet();
	afx_msg void OnBnClickedArm();
	afx_msg void OnLbnSelchangeAnimation();
	afx_msg void OnLbnSelchangeFaceanimation();
	afx_msg void OnCbnSelchangeSex();
	afx_msg void OnCbnSelchangeClass();

public:
	void SelectEquip( char* fileName, int selectPart );
	void SelectItem( char* fileName, int selectPart );
	void SelsectAnimation();
	void GetAnimation();
	void SaveServAni( char *str );
	void SaveServAni( ANILIST* ani );
	void SaveArm( const char* fileName , SMeshContainer* armMesh );
	void LoadAni( int index );
	void SetButtonText(  char* fileName, int selectPart );

public:
	CButton		m_SaveAll;
	CButton		m_SaveChange;
	CButton		m_SaveSelect;
	CComboBox	m_ClassList;
	CComboBox	m_SexList;
	CListBox	m_GeneralAniList;
	CListBox	m_FaceAniList;
	CSliderCtrl m_SDAttackRange;
	ItemList    m_ItemDialog;
	SDrawElement *element;
	ANILIST* anilist;
	MESHINFO minfo;	
	SelectMap<ANILIST*, ANILIST*> m_ListAni;
	SelectMap<string, SMeshContainer*> m_ListArm;
public:
	virtual void OnInitialUpdate();
	afx_msg void OnBnClickedSaveani();
	afx_msg void OnBnClickedSaveServerAni();
	afx_msg void OnBnClickedSavearm();
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnBnClickedTextureconvert();
	afx_msg void OnBnClickedItem();
	afx_msg void OnBnClickedDataSave();
	afx_msg void OnBnClickedAniSave();
	afx_msg void OnBnClickedMeshSave();
	afx_msg void OnBnClickedItemSave();
};
//struct sANIATTR
//{
//	BYTE FPS;
//	BYTE nhit;
//	int* hitstart;
//	int* hitend;
//	POSANIUNIT* pos; 
//
//};
//char SexTable[]={'M','F','N','P'};
//char MeshPartTB[]={'H','F','C','A','B','M','W','L','X'};
//char KindTable[]={'B','S','H','C','F','E','P','M','L','X'};
//char SpareTable1[] = {'X'};
//char SpareTable2[] = {'X'};
//void LoadSeverAni( int sex, int _class, int aniIndex )
//{
//	char buffer[256];
//	sprintf( buffer ,"%cC%c%c%c%06d.ani", SexTable[sex], KindTable[_class], SpareTable1[0], SpareTable2[0], aniIndex );
//
//	sANIATTR ss;
//
//	FILE* pFile = fopen( buffer, "rb" );
//	fread( &ss.FPS, sizeof(BYTE), 1, pFile );
//	fread( &ss.nhit, sizeof(BYTE), 1, pFile );
//	if ( ss.nhit )
//	{
//		ss.hitstart = new int[ss.nhit];
//		ss.hitend = new int[ss.nhit];
//		fread( &ss.hitstart, sizeof(int), ss.nhit, pFile );
//		fread( &ss.hitstart, sizeof(int), ss.nhit, pFile );
//	}
//	int posCount = 0;
//	fread( &posCount, sizeof(int), 1, pFile );
//	ss.pos = new POSANIUNIT[posCount];
//	fread( &ss.pos, sizeof(POSANIUNIT), posCount, pFile );
//	fclose( pFile );
//};

#endif // !defined(AFX_CHARACTERVIEW_H__292645C8_DA72_4DD9_85AC_A177E0ADC651__INCLUDED_)